from jsonpath import jsonpath
import pandas as pd
import json

with open(r"C:\Users\Big Watermelon\Desktop\影刀文件\高级\json\jsonTest.json",'r',encoding='utf-8') as f:
    data = json.loads(f.read())

    '''方法一
    name = jsonpath(data,"$.data[0]..cchilds..name")
    code = jsonpath(data,"$.data[0]..cchilds..code")
    print(name)
    print(code)
    '''

    dataframe = pd.json_normalize(data["data"][0],["clist","pchilds","cchilds"],[["clist","name"],["clist","pchilds","name"]])
    cchilds_list = dataframe.reindex(columns=["clist.name","clist.pchilds.name","name","code"]).values.tolist()
    print(cchilds_list)

